package com.ningxia.water.service.impl;

import com.ningxia.water.entity.ZtDistrictInfo;
import com.ningxia.water.entity.ZtTownInfo;
import com.ningxia.water.mapper.ZtDistrictInfoMapper;
import com.ningxia.water.mapper.ZtTownInfoMapper;
import com.ningxia.water.service.IZtDistrictInfoService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ningxia.water.vo.out.ReportVo;
import com.ningxia.water.vo.out.ZonePidVo;
import com.ningxia.water.vo.out.ZoneVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author hz
 * @since 2021-05-14
 */
@Service
public class ZtDistrictInfoServiceImpl extends ServiceImpl<ZtDistrictInfoMapper, ZtDistrictInfo> implements IZtDistrictInfoService {

    @Autowired
    private ZtDistrictInfoMapper districtInfoMapper;


    @Override
    public List<ZoneVo> getDistrictInfos() {
        return districtInfoMapper.getDistrictInfos();
    }

    @Override
    public Integer findByDistrictId(Integer districtId) {
        return districtInfoMapper.findByDistrictId(districtId);
    }

    @Override
    public List<ZtTownInfo> getAllTown(Integer districtId) {
        return districtInfoMapper.getAllTown(districtId);
    }

    /**
     * 根据传入类型type，判断年报、月报、日报
     *
     * @param type
     * @param currentTime
     * @return
     */
    @Override
    public List<ReportVo> getDistrictReport(String type, String currentTime) {
        if (type.equals("year")) {
            // 年报
            return districtInfoMapper.getDistrictReportByYear(currentTime);
        } else if (type.equals("month")) {
            // 月报
            return districtInfoMapper.getDistrictReportByMonth(currentTime);
        } else if (type.equals("day")) {
            // 日报
            return districtInfoMapper.getDistrictReportByDay(currentTime);
        }
        return null;
    }

    @Override
    public List<ZonePidVo> getDistrictRelationship() {
        return districtInfoMapper.getDistrictRelationship();
    }
}
